home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / map / avail.arc / GETDIRHD.ASM < prev   
Assembly Source File  |  1987-08-06  |  2KB  |  66 lines

  1. ;*****************************************************************************
  2. ; GetDirectoryHandle -- gets the directory handle and status flags 
  3. ;                           associated with a drive number
  4. ;
  5. ; Input:    BYTE driveNumber;        /* The drive number for which the
  6. ;                                      drive handle and status flags should
  7. ;                                      be returned (0=A, 1=B, etc.) */
  8. ;           BYTE *driveHandle;      /* Pointer to the byte where the drive
  9. ;                                      handle associated with the specified
  10. ;                                      drive letter should be returned (OPT)*/
  11. ;           BYTE *statusFlags;      /* Pointer to the byte where the status
  12. ;                                      flags associated with the specified
  13. ;                                      drive letter should be returned (OPT)*/
  14. ;
  15. ; Output:   Returns a 0 in ax if successful or an 0xFF in ax if the specified
  16. ;           drive letter is not mapped to a path.
  17. ;
  18. ;******************   ASSUMING SMALL MODEL FOR LATTICE C V2.15 ***************
  19.  
  20. driveNumber    EQU    byte PTR 4[bp]
  21. handle        EQU    word PTR 6[bp]
  22. status        EQU    word PTR 8[bp]
  23.  
  24.  
  25. PGroup    GROUP    Prog
  26. Prog    SEGMENT    byte public 'PROG'
  27.     ASSUME    cs:PGroup
  28.  
  29.     PUBLIC    GetDirectoryHandle
  30. GetDirectoryHandle    PROC    NEAR
  31.     push    bp            ;Save old frame pointer
  32.     mov    bp, sp            ;Set our frame pointer to current stack pointer
  33.  
  34.     mov    ax, 0e900h        ;Function E9h - "Get Directory Handle"
  35.     mov    dh, 0            ;DH always 0
  36.     mov    dl, driveNumber    
  37.     int    21h            ;Let DOS/Shell handle request
  38.  
  39.     push    si            ;Save SI
  40.     mov    si, word ptr handle    ;
  41.     or    si, si            ;Check if handle==NULL
  42.     jz    no_handle        ; yes, then handle is not wanted
  43.     mov    [si], al        ;  no, then fill in handle
  44. no_handle:
  45.     mov    si, word ptr status    ;
  46.     or    si, si            ;Check if Status==NULL
  47.     jz    no_status        ; yes, then status is not wanted
  48.     mov    [si], ah        ;  no, then fill in status
  49. no_status:
  50.     pop    si            ;Restore SI
  51.  
  52.     cmp    ah, 0            ;If AH==0, then drive NOT mapped
  53.     mov    ax, 0            ;otherwise, drive IS mapped
  54.     jnz    MappingExists            
  55.     mov    ax, 0ffh
  56. MappingExists:
  57.     pop    bp
  58.     ret
  59. GetDirectoryHandle    ENDP
  60.  
  61.     Prog    ENDS
  62.         END
  63.  
  64.  
  65.  
  66.